﻿using ParkSaleForAdmin.Data;
using ParkSaleForAdmin.Foundation;
using System.Windows;

namespace ParkSaleForAdmin.FunctionWindow
{
    class DiscountInfo
    {
        [DataToUI("优惠券编号", false)]
        public string id
        {
            get;
            set;
        }
        [DataToUI("优惠方法代号")]
        public string code
        {
            get;
            set;
        }
        [DataToUI("优惠券归属者")]
        public string belong
        {
            get;
            set;
        }
        [DataToUI("使用订单", false)]
        public string order
        {
            get;
            set;
        }
        [DataToUI("领取时间",false)]
        public string picktime
        {
            get;
            set;
        }
        [DataToUI("参数")]
        public string arg
        {
            get;
            set;
        }
    }
    class Discount : BasicManagerWindow<DiscountInfo>
    {
        public override string TableName => "ownedDiscount";

        int nullable = 0;
        protected override bool NullablePending(string value)
        {
            if (value.Equals("arg"))
            {
                nullable++;
                return true;
            }
            else
                return false;
        }
        protected override void add_Click(object sender, RoutedEventArgs e)
        {
            nullable = 0;
            base.add_Click(sender, e);
        }
        protected override int StandAppendArgsCount => base.StandAppendArgsCount - nullable * 2;
        public override string DeleteStr(DiscountInfo obj)
        {
            return SQLHelpler.MakeSelectStr(TableName, "id", obj.id);
        }

        public override string AppendStr(DiscountInfo obj)
        {
            return SQLHelpler.MakeSelectStr(TableName, "id", "99999999999");
        }

        public override string ChangeStr(DiscountInfo obj)
        {
            return SQLHelpler.MakeSelectStr(TableName, "id", obj.id);
        }
    }
}
